home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / Open Transport 1.3 / Open Transport SDK / Open Tpt Module Developer / Samples / DLPI Template / dlpiether.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-30  |  6.0 KB  |  178 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        dlpiether.h
  3.  
  4.     Contains:    Header file for the DLPI template
  5.              ** dlpiether.h 5.12, last change 30 Jan 1996
  6.  
  7.     Copyright:    © 1995, 1996 by Mentat Inc. and Apple Computer, Inc., all rights reserved.
  8.  
  9. */
  10.  
  11. #ifndef __DLPIETHER__
  12. #define __DLPIETHER__
  13.  
  14. #ifndef __OPENTPTMODULE__
  15. #include <OpenTptModule.h>
  16. #endif
  17. #ifndef __OPENTPTDEVLINKS__
  18. #include <OpenTptDevLinks.h>
  19. #endif
  20. #ifndef __DLPIUSER__
  21. #include "dlpiuser.h"
  22. #endif
  23. #ifndef __DLPI__
  24. #include <dlpi.h>
  25. #endif
  26.  
  27. /* Address list structure */
  28. struct dle_addr_s {
  29.     struct dle_addr_s    * dlea_next;
  30.     UInt8                dlea_addr[6];
  31. };
  32.  
  33. typedef struct dle_addr_s    dle_addr_t;
  34. /*
  35.  * Board-specific routines.  This portion of the dle_t structure must be
  36.  * initialized by the board-specific code before passing the combined
  37.  * structure into dle_install.
  38.  *
  39.  * The dlehw_send_error routine needs to be supplied only if the driver is
  40.  * prepared to send corrupted packets.  If this pointer is NULL in the
  41.  * structure, then the common code will return EINVAL to all kOTSendErrorPacket
  42.  * ioctls.
  43.  *
  44.  * dlehw_recv_error_flags should be initialized by the board code to the
  45.  * errors which can be received by the underlying hardware, such as
  46.  * DL_CRC_ERROR | DL_RUNT_ERROR.  If the board supports receiving corrupted
  47.  * packets, then it should call dle_inbound_error for every bad packet
  48.  * received after the dlehw_address_filter_reset routine has been called with
  49.  * accept_errors > 0.
  50.  */
  51. typedef void    (*DLEHwStartProcPtr)(void *);
  52. typedef void    (*DLEHwStopProcPtr)(void *);
  53. typedef void    (*DLEHwAddressFilterResetProcPtr)
  54.                     (void * hw, dle_addr_t * addr_list, UInt32 addr_count,
  55.                      UInt32 promisc_count, UInt32 multi_promisc_count,
  56.                      UInt32 accept_broadcast, UInt32 accept_errors);
  57. typedef int        (*DLEHWSendErrorProcPtr)(void*, mblk_t*, UInt32);
  58.                      
  59. struct dlehw_s {
  60.     DLEHwStartProcPtr                dlehw_start;
  61.     DLEHwStopProcPtr                dlehw_stop;
  62.     DLEHwAddressFilterResetProcPtr    dlehw_address_filter_reset;
  63.     DLEHWSendErrorProcPtr            dlehw_send_error;
  64.     unsigned long                    dlehw_recv_error_flags;
  65. };
  66.  
  67. typedef struct dlehw_s    dlehw_t;
  68. /* 
  69.  * There is one dle_t structure allocated for each controlled device
  70.  * being managed by the common Ethernet code in dlpiether.c.  The 
  71.  * board-specific code should allocate its own control structure for
  72.  * each board, with a dle_t structure at the top.  For example:
  73.  *
  74.  *    struct board_s {
  75.  *        dle_t    board_dle;
  76.  *        int        board_field1;
  77.  *        void    * board_field2;
  78.  *    };
  79.  *
  80.  * Typically, the board-specific code only needs to know about the dle_hw,
  81.  * dle_addr, and dle_status fields of this internal structure.  The rest of
  82.  * the fields are used by the common Ethernet code in dlpiether.c.
  83.  */
  84. struct dle_s {
  85.     dlehw_t                    dle_hw;                            /* Board-specific routines */
  86.     UInt8                    dle_factory_addr[6];            /* Factory physical address */
  87.     UInt8                    dle_current_addr[6];            /* Current physical Ethernet address */
  88. volatile UInt32                dle_intr_active;
  89.     dle_interface_status_t    dle_istatus;                    /* Interface MIB statistics */
  90.     dle_ethernet_status_t    dle_estatus;                    /* Ethernet MIB statistics */
  91.     void                    * dle_sap_hash_tbl[64];            /* Hash table of sap binds */
  92.     void                    * dle_match_any;                /* List of promiscuous binds */
  93.     void                    * dle_match_any_multicast;        /* List of promiscuous multicast binds */
  94.     void                    * dle_match_matched;            /* List of binds for packets that have */
  95.                                                             /* matched at least one other binding (!) */
  96.     void                    * dle_match_any_802;            /* List of promiscuous 802 binds */
  97.     void                    * dle_bind_list;                /* Linked list of all binds */
  98.     UInt32                    dle_bound_count;                /* Number of binds */
  99.     UInt32                    dle_match_any_count;            /* Number of promiscuous binds */
  100.     UInt32                    dle_match_any_multicast_count;    /* Number in dle_match_any_multicast */
  101.     void                    * dle_hw_addr_list;                /* List of all physical and multicast addresses */
  102.                                                             /* that should be received by the hardware. */
  103.     UInt32                    dle_refcnt;
  104.     UInt32                    dle_xtra_hdr_len;                /* Any extra space the board code */
  105.                                                             /* needs at the top of outbound */
  106.                                                             /* M_DATA messages */
  107.     UInt32                    dle_min_sdu;                    /* Minimum transmit size from clients */
  108.     char                    * dle_instance_head;
  109.     UInt32                    dle_reserved[6];                /* Set to 0 */
  110. };
  111.  
  112. typedef struct dle_s    dle_t;
  113. /*
  114.  * DLPI client structure; one created for each open stream (held in q->q_ptr).
  115.  * If a board driver needs more space than given here, it should declare its
  116.  * own structure with this dcl_t as the first element.  The size of the new
  117.  * structure should be passed to dle_open so that the proper amount of space
  118.  * is allocated.
  119.  */
  120. struct dcl_s {
  121.     UInt32        dcl_state;
  122.     void        * dcl_hw;
  123.     queue_t        * dcl_rq;
  124.     UInt32        dcl_flags;
  125.     UInt32        dcl_sap;
  126.     UInt8        dcl_snap[5];
  127.     char        dcl_pad[3];
  128.     UInt32        dcl_mac_type;
  129.     UInt32        dcl_framing_type;
  130.     void        * dcl_addr_list;
  131.     UInt32        dcl_truncation_length;
  132.     UInt32        dcl_reserved[1];
  133. };
  134.  
  135. typedef struct dcl_s    dcl_t;
  136.  
  137. /*
  138.  * if dle_xtra_hdr_len != 0, then the following check needed for M_DATA
  139.  * messages in write-side put procedure:
  140.  *
  141.  *    if (dcl->dcl_flags & F_DCL_M_PROTO_REQUESTED) {
  142.  *        'raw mode' --> need to insert dle_xtra_hdr_len bytes
  143.  *        in front of b_rptr (start of Ethernet frame).
  144.  *        ...
  145.  *    } else {
  146.  *        This is a Fast Path packet with dle_xtra_hdr_len bytes
  147.  *        at b_rptr.
  148.  *        ...
  149.  *    }
  150.  */
  151. #define    F_DCL_M_PROTO_REQUESTED    0x80
  152.  
  153. /* Conversion macros between the different co-allocated structures. */
  154. #define    dcl_to_dle(dcl)    ((dle_t *)(dcl)->dcl_hw)
  155. #define    dle_to_hw(dle)    ((void *)(dle))
  156.  
  157. /* Routines in the common code available to board-specific routines. */
  158.  
  159. #ifdef __cplusplus
  160. extern "C" {
  161. #endif
  162.  
  163. extern    int        dle_close(queue_t * q);
  164. extern    void    dle_inbound(dle_t * dle, mblk_t * mp);
  165. extern    void    dle_inbound_error(dle_t * dle, mblk_t * mp, UInt32 flags);
  166. extern    void    dle_init(dle_t * dle, size_t xtra_hdr_len);
  167. extern    int        dle_open(dle_t * dle, queue_t * q, dev_t * devp, int flag, int sflag, cred_t * credp, size_t dcl_len);
  168. extern    void    dle_rsrv_ctl(queue_t * q, mblk_t * mp);
  169. extern    void    dle_terminate(dle_t * dle);
  170. extern    mblk_t    * dle_wput(queue_t * q, mblk_t * mp);
  171. extern    mblk_t    * dle_wput_ud_error(mblk_t * mp, int dlpi_err, int unix_err);
  172.  
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176.  
  177. #endif
  178.